export default {
	data() {
		return {
			loading: false,
			startX: 0, // 触摸起始位置的 X 坐标
			moveX: 0, // 触摸移动的距离
			threshold: 240,

		};
	},
	methods: {
		onTouchStart(e) {
			// 记录触摸起始位置的 X 坐标
			this.startY = e.changedTouches[0].clientY;
		},
		onTouchMove(e) {
			// 计算触摸移动的距离
			this.moveY = e.changedTouches[0].clientY - this.startY;
		},
		onTouchEnd() {
			if (this.moveY > this.threshold) {
				if (!this.online) {
					uni.showToast({
						title: '当前处于脱机状态',
						icon: 'none'
					})
				} else {

					this.loading = true
					const start = Date.now()
					this.requestTasks().finally(res => {
						const now = Date.now()
						const timeout = start + 1500 - now > 0 ? start + 1500 - now : 0
						setTimeout(() => {
							this.loading = false
						}, timeout)
					})
				}
			}
			// 重置移动距离
			this.moveY = 0;
		}
	}
}